package cn.ichiva.puppet.example.base.p1;

import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.fxml.FXML;
import javafx.fxml.impl.AbstractPuppetComponent;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.layout.VBox;

/**
 * 条件渲染,事件绑定
 */
public class L3StyleComponent extends AbstractPuppetComponent {

    @FXML
    StringProperty style = new SimpleStringProperty("-fx-text-fill: red;");

    @Override
    public CharSequence render() {
        imports(VBox.class, Label.class, Button.class);
        return """
                <VBox>
                    <Label text="打螺丝" style="${style}" />
                    <Button text="添加边框" onAction="#addBorder" />
                </VBox>
                """;
    }

    @FXML
    void addBorder(){
        style.set(style.get() + "-fx-border-width: 1;-fx-border-style: solid;-fx-border-color: red");
    }

}
